home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / SCHEME / GNU / SCM4E1 / !Scm / slib / macrotst < prev    next >
Text File  |  1992-02-03  |  921b  |  49 lines

  1. ;;;; macrotst.scm Test for R4RS Macros
  2. ;;; From Revised^4 Report on the Algorithmic Language Scheme
  3. ;;; William Clinger and Jonathon Rees (Editors)
  4.  
  5. ;;; To run this code type
  6. ;;; (require 'macro)
  7. ;;; (macro:load "macrotst.scm")
  8.  
  9. (write "this code should print now, outer, and 7") (newline)
  10.  
  11. (write
  12.  (let-syntax ((when (syntax-rules ()
  13.                   ((when test stmt1 stmt2 ...)
  14.                    (if test
  15.                        (begin stmt1
  16.                           stmt2 ...))))))
  17.    (let ((if #t))
  18.      (when if (set! if 'now))
  19.      if)))
  20. (newline)
  21. ;;;            ==> now
  22.  
  23. (write
  24.  (let ((x 'outer))
  25.    (let-syntax ((m (syntax-rules () ((m) x))))
  26.      (let ((x 'inner))
  27.        (m)))))
  28. (newline)
  29. ;;;            ==> outer
  30. (write
  31.  (letrec-syntax
  32.   ((or (syntax-rules ()
  33.      ((or) #f)
  34.      ((or e) e)
  35.      ((or e1 e2 ...)
  36.       (let ((temp e1))
  37.         (if temp temp (or e2 ...)))))))
  38.   (let ((x #f)
  39.     (y 7)
  40.     (temp 8)
  41.     (let odd?)
  42.     (if even?))
  43.     (or x
  44.     (let temp)
  45.     (if y)
  46.     y))))
  47. (newline)
  48. ;;;            ==> 7
  49.